# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : KNN算法实现分类（一维）.py
# @Author: dongguangwen
# @Date  : 2025-01-19 14:03
# 1.导入工具包
from sklearn.neighbors import KNeighborsClassifier

# 2.数据（特征工程）
x = [[0], [1], [2], [3], [4]]
y = [0, 0, 1, 1, 1]

# 3.实力化
model = KNeighborsClassifier(n_neighbors=3)

# 4.训练
model.fit(x, y)

# 5.预测
print(model.predict([[5]]))
